/**
 * 按钮点击次数统计并更新到浏览器title栏
 */
 import React, { useState, useEffect } from "react";

 const Counter = () => {
   // 引入状态和修改状态的方法
   const [count, setCount] = useState(0);
   // 点击按钮修改状态
   const handleCount = () => {
     setCount(count + 1);
   };
   // 使用useEffect修改标题栏
   useEffect(() => {
     document.title = `按钮被点击了${count}次`;
   });
 
   return (
     <div>
       <button onClick={handleCount}>按钮被点击了{count}次</button>
     </div>
   ) 
 };
 
 export default Counter;
 